package com.ilink.groundservice.service.impl.dataset;/**
 * <h3>iLink-java-backend-zhangbo2</h3>
 *
 * @Description <p>针对【dataset_tags】的服务实现类</p>
 * @Author ZhangBo
 * @Date 2024-09-15 21:17
 **/

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ilink.groundservice.entity.PO.dataset.DatasetTags;
import com.ilink.groundservice.mapper.dataset.DatasetTagsMapper;
import com.ilink.groundservice.service.dataset.DatasetTagsService;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * @ClassName DatasetTagsServiceImpl
 * @Description 针对【dataset_tags】的服务实现类
 * @Author ZhangBo
 * @Date 2024-09-15 21:17
 **/
@Service
@RequiredArgsConstructor
public class DatasetTagsServiceImpl extends ServiceImpl<DatasetTagsMapper, DatasetTags>
    implements DatasetTagsService {
    private final DatasetTagsMapper datasetTagsMapper;

    /**
     * @Author ZhangBo
     * @Description 获取数据集标签数量
     * @Date 16:45 2024/9/16
     * @Param []
     * @return long
     **/

    /**
     * @Author DiaoZhongYang
     * @Description 查询最常使用的8个标签
     * @Date 18:39 2024/9/16
     * @Param []
     * @return java.util.List<java.lang.String>
     **/
    @Override
    public List<String> getCommonTags(int num) {
        try{
            List<String> commonTags = datasetTagsMapper.selectCommonTags(num);
            if(commonTags != null){
                return commonTags;
            }
            return null;
        }catch (Exception e){
            log.error(e.getMessage());
            return null;
        }
    }

    @Override
    public long getTagsCount() {
        // 使用 MyBatis Plus 提供的 selectCount 方法，统计不同 tag 的数量
        return datasetTagsMapper.selectTagsCount();
    }
}
